home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / fixes / java125 / applet1.java < prev    next >
Encoding:
Java Source  |  1996-12-03  |  1.7 KB  |  65 lines

  1. /*
  2.     A basic extension of the java.applet.Applet class
  3.  */
  4.  
  5. import java.awt.*;
  6. import java.applet.*;
  7.  
  8. public class Applet1 extends Applet {
  9.  
  10.     public void init() {
  11.         super.init();
  12.  
  13.         //{{INIT_CONTROLS
  14.         setLayout(null);
  15.         addNotify();
  16.         resize(311,211);
  17.         verticalScrollbar1 = new java.awt.Scrollbar(Scrollbar.VERTICAL,0,0,0,200);
  18.         verticalScrollbar1.reshape(140,60,16,120);
  19.         add(verticalScrollbar1);
  20.         label1 = new java.awt.Label("0");
  21.         label1.reshape(42,75,70,15);
  22.         label1.setFont(new Font("Dialog", Font.BOLD, 12));
  23.         add(label1);
  24.         label2 = new java.awt.Label("0");
  25.         label2.reshape(203,75,70,15);
  26.         label2.setFont(new Font("Dialog", Font.BOLD, 12));
  27.         add(label2);
  28.         label3 = new java.awt.Label("Centigrade");
  29.         label3.reshape(42,53,84,15);
  30.         add(label3);
  31.         label4 = new java.awt.Label("Fahrenheit");
  32.         label4.reshape(203,53,70,15);
  33.         label4.setFont(new Font("Dialog", Font.PLAIN, 12));
  34.         add(label4);
  35.         label5 = new java.awt.Label("0 -");
  36.         label5.reshape(105,68,28,15);
  37.         label5.setFont(new Font("Dialog", Font.ITALIC, 12));
  38.         add(label5);
  39.         label6 = new java.awt.Label("200 -");
  40.         label6.reshape(98,158,42,15);
  41.         label6.setFont(new Font("Dialog", Font.ITALIC, 12));
  42.         label6.setForeground(new Color(0));
  43.         add(label6);
  44.         //}}
  45.     }
  46.  
  47.     public boolean handleEvent(Event event) {
  48.          if (event.target == verticalScrollbar1) {
  49.             label1.setText(""+verticalScrollbar1.getValue());
  50.             label2.setText(""+(((verticalScrollbar1.getValue() * 9) / 5) + 32));
  51.         }
  52.         return super.handleEvent(event);
  53.     }
  54.  
  55.     //{{DECLARE_CONTROLS
  56.     java.awt.Scrollbar verticalScrollbar1;
  57.     java.awt.Label label1;
  58.     java.awt.Label label2;
  59.     java.awt.Label label3;
  60.     java.awt.Label label4;
  61.     java.awt.Label label5;
  62.     java.awt.Label label6;
  63.     //}}
  64. }
  65.